package com.java.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.java.service.RaceFeedbackService;
import com.java.util.resp.BaseRespone;
import com.java.util.resp.TableRespone;
import com.java.util.servlet.ServletUtil;

@RestController
//@RequestMapping("/feedback")
public class RaceFeedbackController {

	@Autowired
	private RaceFeedbackService feedbackService;
	
	@PostMapping("/createFeedback")
	public BaseRespone createFeedback(
			@RequestParam(required = false) String userId,
			@RequestParam(required = false) String feedbackContent) {
		return feedbackService.createFeedback(ServletUtil.getUserId(userId), feedbackContent);
	}

	@PostMapping("/replyFeedback")
	public BaseRespone replyFeedback(
			@RequestParam(required = false) String feedbackId,
			@RequestParam(required = false) String feedbackReply) {
		return feedbackService.replyFeedback(feedbackId,feedbackReply);
	}

	@PostMapping("/delFeedback")
	public BaseRespone delFeedback(@RequestParam(required = false) String feedbackId) {
		return feedbackService.delFeedback(feedbackId);
	}

	@PostMapping("/getFeedbacks")
	public TableRespone getFeedbacks(@RequestParam(required = false) String userId,
			@RequestParam(required = false, defaultValue = "0") int page,
			@RequestParam(required = false, defaultValue = "0") int size) {
		return feedbackService.getFeedbacks(ServletUtil.getUserId(userId), page, size);
	}
}
